com.cete.dynamicpdf
Class BoundingBox


Example:The following example shows how to add bounding box to the rectangle.

import com.cete.dynamicpdf.*;
import com.cete.dynamicpdf.pageelements.*;
 
public class MyClass{
      public static void main(String args[]){
          
          // Create a PDF Document
          Document document = new Document();

          // Specify document as a tagged PDF
          document.setTag(new TagOptions());
         
          // Create a page and add it to the document
          Page page = new Page();
	  document.getPages().add(page);

          // Create a rectangle
          Rectangle rectangle = new Rectangle(100, 100, 100, 100, RgbColor.getBlack(), RgbColor.getBlue());
        
          // Create a structure element
          StructureElement structureElement = new StructureElement(TagType.getFigure());
        
          // Create an attribute object
          AttributeObject attributeObject = new AttributeObject(AttributeOwner.LAYOUT);
          attributeObject.setHeight(); // Sets default value to the height attribute
          attributeObject.setWidth(); //  Sets default value to the width attribute
        
          // Calclulates bounding box and Add it to the bounding box attribute
          attributeObject.setBoundingBox(new BoundingBox(page, rectangle.getX(), rectangle.getY(), rectangle.getWidth(), rectangle.getHeight(), rectangle.getAngle()));
        
          // Add attribute object to the structure element
          structureElement.getAttributeLists().add(attributeObject);
        
          // Tag the rectangle with the structure element
          rectangle.setTag(structureElement);
        
          // Add rectangle to the page
          page.getElements().add(rectangle);

          //Save the PDF
          document.draw("[PhysicalPath]/MyDocument.pdf" );
      }
}